<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js" type="application/javascript"></script>
</head>
<body>
  <div id="app">
    <!-- 传标签内容到子组件,方式1-通过父传子 -->
    <no-use-slot :title="title"></no-use-slot>
    <!-- 传标签内容到子组件,方式2-通过插槽 -->
    <use-slot>
      <h3>标题</h3>
    </use-slot>
  </div>
</body>
<script>
  //默认插槽
  //用途: 子组件用来接受父组件传过来标签内容
  //特征:
  //   在父组件当中,子组件的标签题里面传标签
  //   在子组件当中,通过slot标签接受内容
  //优点:
  //   过程更简单
  Vue.component('no-use-slot',{
    props: ['title'],
    template: `
      <div>不用插槽的子组件-<div v-html="title"></div></div>
    `
  })
  Vue.component('use-slot',{
    template: `
      <div>用插槽的子组件-<slot></slot></div>
    `
  })
  new Vue({
    el: '#app',
    data() {
      return {
        title: '<h3>标题</h3>'
      }
    },
    created() {},
    mounted() {
    },
    methods: {
    },
  })
</script>
</html>
